package com.ruoyi.shuati.config;

import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

@Component
public class WxMpConfig {
    @Value("${weixin.appId}")
    private String AppId;

    @Value("${weixin.appSecret}")
    private String Secret;


    @Bean
    public WxMpService wxMpService(){
        WxMpService wxMpService = new WxMpServiceImpl();
        WxMpDefaultConfigImpl config = new WxMpDefaultConfigImpl();
        config.setAppId(AppId); // 设置微信公众号的appid
        config.setSecret(Secret); // 设置微信公众号的app corpSecret
        wxMpService.setWxMpConfigStorage(config);
        return wxMpService;
    }
}
